var UserNO = localStorage.getItem("UserNO");
mui.plusReady(function() {
	$("#MaterialCode").focus();
	plus.nativeUI.closeWaiting();
	$("#MaterialCode").keyup(function(event) {
		event.preventDefault();
		if (event.keyCode == 13) {
			var BarCodeNO = $("#MaterialCode").val();
			if (!BarCodeNO) {
				mui.toast("Please scan the Material Barcode。", {
					duration: '1000',
					type: 'div'
				});
				BarCodeNO.focus();
				return false;
			}

			if (BarCodeNO.indexOf("||") !== -1) { // 或者用 includes("||")
				BarCodeNO = BarCodeNO.split("||")[0];
				//console.log("解析到的条码:", firstBarcode); 
			}
			$("#MaterialCode").val(BarCodeNO);
			// var barcodeList = [{
			// 	BarcodeNO: BarCodeNO
			// }];
			try {
				xccFormPostAsync("api/PDA/OutFistMaterialBarcode", {
					BarcodeNO: BarCodeNO
				}, function(data) {
					console.log(data);
					$("#txtResult").val(BarCodeNO + ",Success!");
					$("#MaterialCode").val('');
					$("#MaterialCode").focus();
				}, function(error) {
					console.log("1");
					$("#txtResult").val(BarCodeNO + "," + error.responseText);
					$("#MaterialCode").val('');
					$("#MaterialCode").focus();
				});
			} catch (e) {
				console.log(e);
			}

		}

	});

})